home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ecstr3.arc / MEMMOV.C < prev    next >
C/C++ Source or Header  |  1987-03-04  |  1KB  |  43 lines

  1. /*  File   : memmov.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 25 May 1984
  4.     Defines: memmov()
  5.  
  6.     memmov(dst, src, len)
  7.     moves len bytes from src to dst.  The result is dst+len.
  8.     This is to memcpy as str[n]mov is to str[n]cpy, that is, it moves
  9.     exactly the same bytes but returns a pointer to just after the
  10.     the last changed byte.  You can concatenate blocks pa for la,
  11.     pb for lb, pc for lc into area pd by doing
  12.        memmov(memmov(memmov(pd, pa, la), pb, lb), pc, lc);
  13.     Unlike strnmov, memmov does not stop when it hits a NUL byte.
  14.  
  15.     Note: the VAX assembly code version can only handle 0 <= len < 2^16.
  16.     It is presented for your interest and amusement.
  17. */
  18.  
  19. #include "strings.h"
  20.  
  21. #if    VaxAsm
  22.  
  23. char *memmov(dst, src, len)
  24.     char *dst, *src;
  25.     int len;
  26.     {
  27.        asm("movc3 12(ap),*8(ap),*4(ap)");
  28.      return dst+len;
  29.     }
  30.  
  31. #else  ~VaxAsm
  32.  
  33. char *memmov(dst, src, len)
  34.     register char *dst, *src;
  35.     register int len;
  36.     {
  37.        while (--len >= 0) *dst++ = *src++;
  38.        return dst;
  39.     }
  40.  
  41. #endif VaxAsm
  42.  
  43.